//
//  HTDeliverGoodsVC.m
//  TruckUser
//
//  Created by Ting Han on 2017/10/16.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTDeliverGoodsVC.h"
#import "UIView+Layout.h"
#import "HTMLocationManager.h"

#import "HTDeliverPlaceChoiceView.h"
//车长车型
#import "HTDeliverTruckTypeView.h"
//货物类型
#import "HTGoodsTypeView.h"
//时间
#import "HTDateView.h"
//其他信息
#import "HTAlertOtherView.h"
#import "HTDeliverGoodsInfoModel.h"

#define NUMBERS @"0123456789.\n"

@interface HTDeliverGoodsVC ()<HTDeliverPlaceChoiceViewDelegte,HTGoodsTypeViewDelegate,HTDateViewDelegate,HTAlertOtherViewDelegate,HTDeliverTruckTypeViewDelegate,UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIView *bagView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollHeight;
@property (weak, nonatomic) IBOutlet UILabel *startLabel;
@property (weak, nonatomic) IBOutlet UILabel *destiLabel;
@property (weak, nonatomic) IBOutlet UILabel *truckTypeLabel;
@property (weak, nonatomic) IBOutlet UILabel *goodsTypeLabel;
@property (weak, nonatomic) IBOutlet UITextField *heavyTextField;
@property (weak, nonatomic) IBOutlet UITextField *moneyTextField;
@property (weak, nonatomic) IBOutlet UILabel *otherLabel;

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UIButton *dunButton;
@property (weak, nonatomic) IBOutlet UIButton *fangButton;
@property (weak, nonatomic) IBOutlet UIButton *conformButton;
@property (weak, nonatomic) IBOutlet UIView *tapLeftView;
@property (weak, nonatomic) IBOutlet UIView *tapRightView;
@property (weak, nonatomic) IBOutlet UIView *tapMiddleView;
@property (weak, nonatomic) IBOutlet UIImageView *tapLeftImage;
@property (weak, nonatomic) IBOutlet UIImageView *tapRightImage;
@property (weak, nonatomic) IBOutlet UIImageView *tapMiddleImage;
@property (weak, nonatomic) IBOutlet UILabel *tapLeftLabel;
@property (weak, nonatomic) IBOutlet UILabel *tapMiddleLabel;
@property (weak, nonatomic) IBOutlet UILabel *tapRightLabel;

@property (nonatomic,weak) UIButton *selectedBtn;

@property (nonatomic,strong)UITapGestureRecognizer *tap1;
@property (nonatomic,strong)UITapGestureRecognizer *tap2;
@property (nonatomic,strong)UITapGestureRecognizer *tap3;


#pragma mark --- 网络请求数据处理
@property (nonatomic,strong) NSString *startAddressString;
@property (nonatomic,strong) NSString *endAddressString;
@property (nonatomic,strong) NSString *startProvince;
@property (nonatomic,strong) NSString *endProvince;
@property (nonatomic,strong) NSString *cargotypeString;//整车、零担
@property (nonatomic,strong) NSString *lenghtString;//车长
@property (nonatomic,strong) NSString *lengthtypeString;//车型
@property (nonatomic,strong) NSString *weightString;//货物重量
@property (nonatomic,strong) NSString *utitString;//单位
@property (nonatomic,strong) NSString *pricersString;//运费
@property (nonatomic,strong) NSString *strattimeString;//装车时间
@property (nonatomic,strong) NSString *paytypeString;//付款方式
@property (nonatomic,strong) NSString *addtypeString;//装卸方式
@property (nonatomic,strong) NSString *remarkString;//备注
@property (nonatomic,strong) NSString *boostimeString;//隔几分钟发一次
@property (nonatomic,strong) NSString *iscityString;//同城可见
@property (nonatomic,strong) NSString *isworkesString;//常发货源
@property (nonatomic,strong) NSString *goodstypeString;//货物类型

@property (nonatomic,strong) HTDeliverGoodsInfoModel *deliverGoodsInfoModel;

@end

@implementation HTDeliverGoodsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initData];
    [self loadLocation];
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self turnData];
}
- (void)turnData{
    if (self.orderid == nil || self.orderid.length <= 0) {
        return;
    }
    [self netLoadEditData];
}
- (void)loadLocation{
    if ([[HTMLocationManager singleInstance] getCurrentAddress].length <= 0) {
        //定位请求
        [self requestLocation];
        self.startLabel.text = @"北京";
        self.startProvince = @"北京";
    }else{
        self.startLabel.text = [[HTMLocationManager singleInstance] getCurrentAddress];
        self.startProvince =  [[HTMLocationManager singleInstance] getCurrentProvince];
    }
    self.startAddressString = self.startLabel.text;
    self.startLabel.textColor = [UIColor blackColor];
}
- (void)requestLocation{
    [[HTMLocationManager singleInstance]requestLocationCompletionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
        if (error)
        {
            if (error.code == AMapLocationErrorLocateFailed)
            {
                [HTShowUtil showMessage:@"定位失败"];
                return;
            }
        }
        if (regeocode)
        {
            if (regeocode.city == nil || regeocode.city.length <= 0) {
                self.startLabel.text = @"北京";
                self.startAddressString = self.startLabel.text;
                self.startProvince = @"北京";
                return;
            }
            [HTMLocationManager singleInstance].currentCity = regeocode.city;
            [HTMLocationManager singleInstance].currentProvince = regeocode.province;
           self.startLabel.text =  [[HTMLocationManager singleInstance]getCurrentAddress];
            self.startProvince = [[HTMLocationManager singleInstance]getCurrentProvince];
           self.startAddressString = self.startLabel.text;
        }
    }];
}
- (void)didTapGestureAlert:(UITapGestureRecognizer *)tap{
    [self.heavyTextField resignFirstResponder];
    [self.moneyTextField resignFirstResponder];
    switch (tap.view.tag) {
        case 111://出发地
        {
            HTDeliverPlaceChoiceView *deliver = [[HTDeliverPlaceChoiceView alloc]initWithFrame:[UIScreen mainScreen].bounds];
            deliver.deliverPlaceChoiceType = HTDeliverPlaceChoiceTypeStart;
            deliver.delegate = self;
            [deliver showView];
        }
            break;
        case 112://目的地
        {
            HTDeliverPlaceChoiceView *deliver = [[HTDeliverPlaceChoiceView alloc]initWithFrame:[UIScreen mainScreen].bounds];
            deliver.deliverPlaceChoiceType = HTDeliverPlaceChoiceTypeDestination;
            deliver.delegate = self;
            [deliver showView];
        }
            break;
        case 113://车长车型
        {
            HTDeliverTruckTypeView *deliver = [[HTDeliverTruckTypeView alloc]init];
            deliver.delegate = self;
            [deliver showView];
        }
            break;
        case 114://货物类型
        {
            HTGoodsTypeView *goodsType = [[HTGoodsTypeView alloc]init];
            goodsType.delegate = self;
            [goodsType showView];
        }
            break;
        case 115://装车时间
        {
            HTDateView *data = [[HTDateView alloc]init];
            data.delegate = self;
            [data showView];
        }
            break;
        case 116://其他信息
        {
            HTAlertOtherView *other = [[HTAlertOtherView alloc]init];
            other.delegate = self;
            [other showView];
            
        }
            break;
        default:
            break;
    }
    
}
- (void)didTapGesture:(UITapGestureRecognizer *)tap{
    switch (tap.view.tag) {
        case 101:
        {
             self.tapLeftImage.hidden =  !self.tapLeftImage.hidden;
            if (self.tapLeftImage.hidden) {
                self.tapLeftLabel.textColor = [UIColor blackColor];
            }else{
                 self.tapLeftLabel.textColor = kBlueColor;
            }
        }
            break;
        case 102:
        {
            self.tapMiddleImage.hidden = ! self.tapMiddleImage.hidden;
            if (self.tapMiddleImage.hidden) {
                self.tapMiddleLabel.textColor = [UIColor blackColor];
            }else{
                self.tapMiddleLabel.textColor = kBlueColor;
            }
        }
            break;
        case 103:
        {
            self.tapRightImage.hidden = !self.tapRightImage.hidden;
            if (self.tapRightImage.hidden) {
                self.tapRightLabel.textColor = [UIColor blackColor];
            }else{
                self.tapRightLabel.textColor = kBlueColor;
            }
        }
            break;
        default:
            break;
    }
}
- (IBAction)clickDun:(UIButton *)sender {
    if (self.selectedBtn == self.dunButton) {
        return;
    }
    self.selectedBtn = self.dunButton;
    self.dunButton.layer.borderColor = kBlueColor.CGColor;
    self.dunButton.backgroundColor = kBlueColor;
    [self.dunButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.fangButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.fangButton.backgroundColor = [UIColor whiteColor];
    [self.fangButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
}
- (IBAction)clickFang:(UIButton *)sender {
    if (self.selectedBtn == self.fangButton) {
        return;
    }
    self.selectedBtn = self.fangButton;
    self.fangButton.layer.borderColor = kBlueColor.CGColor;
    self.fangButton.backgroundColor = kBlueColor;
    [self.fangButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.dunButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.dunButton.backgroundColor = [UIColor whiteColor];
    [self.dunButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}
#pragma mark --- 出发地目的地 delegate
- (void)didChoiceItemWithHistory:(HTAreaModel *)areaModel deliverType:(HTDeliverPlaceChoiceType)deliverType{
    NSString *place = [HTUtils placePostStringWith:areaModel];
    if (deliverType == HTDeliverPlaceChoiceTypeStart) {//出发地
        self.startLabel.text = place;
        self.startLabel.textColor = [UIColor blackColor];
        self.startAddressString = self.startLabel.text;
        self.startProvince = areaModel.provinceString;
    }
    if (deliverType == HTDeliverPlaceChoiceTypeDestination) {//目的地
        self.destiLabel.text = place;
        self.destiLabel.textColor = [UIColor blackColor];
        self.endAddressString = self.destiLabel.text;
        self.endProvince = areaModel.provinceString;
    }
}
- (void)didChoiceItemWithAreaModel:(HTAreaModel *)areaModel currentIndex:(NSInteger)currentIndex deliverType:(HTDeliverPlaceChoiceType)deliverType{
    if (areaModel.areaType == HTAreaTypeNo || areaModel.areaType == HTAreaTypeArea) {
        NSString *place = [HTUtils placePostStringWith:areaModel];
        if (deliverType == HTDeliverPlaceChoiceTypeStart) {//出发地
            self.startLabel.text = place;
            self.startLabel.textColor = [UIColor blackColor];
            self.startAddressString = self.startLabel.text;
            self.startProvince = areaModel.provinceString;
        }
        if (deliverType == HTDeliverPlaceChoiceTypeDestination) {//目的地
            self.destiLabel.text = place;
            self.destiLabel.textColor = [UIColor blackColor];
            self.endAddressString = self.destiLabel.text;
            self.endProvince = areaModel.provinceString;
        }
    }
}
#pragma mark --- 车长车型弹框 delegate
- (void)didChoiceLengths:(NSMutableArray *)lengthsData truckType:(NSString *)truckType isLessThan:(BOOL)isLessThan{
    self.lenghtString = [HTUtils sortLengthDataStringWithArray:lengthsData];
    self.lengthtypeString = truckType;
    NSString *total = @"";
    NSString *length = [HTUtils sortLengthDataDisplayStringWithArray:lengthsData];
    if (isLessThan) {
        total = @"零担";
        self.cargotypeString = @"1";
    }else{
        total = @"整车";
        self.cargotypeString = @"0";
    }
    if (truckType.length <= 0) {
        total = [NSString stringWithFormat:@"%@ %@ 不限车型 ",total,length];
    }else{
         total = [NSString stringWithFormat:@"%@ %@ %@",total,length,truckType];
    }
    self.truckTypeLabel.text = total;
    self.truckTypeLabel.textColor = [UIColor blackColor];
}
#pragma mark --- 货物类型弹框 delegate
- (void)didChoseTypeItem:(NSString *)item{
    
    self.goodsTypeLabel.text = item;
    self.goodsTypeLabel.textColor = [UIColor blackColor];
    self.goodstypeString = item;
}
#pragma mark --- 装车时间 delegate
- (void)didChoseTime:(NSString *)time{
    
    self.timeLabel.text = time;
    self.timeLabel.textColor = [UIColor blackColor];
    self.strattimeString = time;
    
}
#pragma mark --- 其他信息 delegate
- (void)didConformWithMessage:(NSString *)message withPayType:(NSString *)paytype withAddType:(NSString *)addType withRemark:(NSString *)remark{
    self.otherLabel.text = message;
    self.otherLabel.textColor = [UIColor blackColor];
    self.paytypeString = paytype;
    self.addtypeString = addType;
    self.remarkString = remark;
}

#pragma mark -- 初始化
- (void)initData{
//    self.heavyTextField.keyboardType = UIKeyboardTypeNumberPad;
//    self.moneyTextField.keyboardType = UIKeyboardTypeNumberPad;
    if (self.conformButton.bottom + 20  > kHTScreenHeight - kHTToolBarHeight) {
        self.scrollHeight.constant = self.conformButton.bottom + 20;
    }else{
        self.scrollHeight.constant = kHTScreenHeight - kHTNavicationBarAndStatusBar;
    }
    [self.bagView layoutIfNeeded];
    [self.heavyTextField setValue:[UIColor darkGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
    [self.heavyTextField setValue:[UIFont systemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];
    [self.moneyTextField setValue:[UIColor darkGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
    [self.moneyTextField setValue:[UIFont systemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];
    self.moneyTextField.delegate = self;
    self.heavyTextField.delegate = self;
    self.dunButton.layer.masksToBounds = YES;
    self.dunButton.layer.cornerRadius = 4;
    self.dunButton.layer.borderWidth = 0.3;
    self.dunButton.layer.borderColor = kBlueColor.CGColor;
    self.dunButton.backgroundColor = kBlueColor;
    [self.dunButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.fangButton.layer.masksToBounds = YES;
    self.fangButton.layer.cornerRadius = 4;
    self.fangButton.layer.borderWidth = 0.3;
    self.fangButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.fangButton.backgroundColor = [UIColor whiteColor];
    [self.fangButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    self.selectedBtn = self.dunButton;
    self.conformButton.layer.masksToBounds = YES;
    self.conformButton.layer.cornerRadius = 12;
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGesture:)];
    self.tapLeftView.tag = 101;
    [self.tapLeftView  addGestureRecognizer:tap1];
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGesture:)];
    self.tapMiddleView.tag = 102;
    [self.tapMiddleView  addGestureRecognizer:tap2];
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGesture:)];
    self.tapRightView.tag = 103;
    [self.tapRightView  addGestureRecognizer:tap3];
    self.tapLeftImage.hidden = NO;
    self.tapLeftLabel.textColor = kBlueColor;
    self.tapMiddleImage.hidden = YES;
    self.tapRightImage.hidden = YES;
    self.tap1 = tap1;
    self.tap2 = tap2;
    self.tap3 = tap3;
    
    UITapGestureRecognizer *tap11 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGestureAlert:)];
    self.startLabel.tag = 111;
    self.startLabel.userInteractionEnabled = YES;
    [self.startLabel  addGestureRecognizer:tap11];
    UITapGestureRecognizer *tap12 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGestureAlert:)];
    self.destiLabel.tag = 112;
    self.destiLabel.userInteractionEnabled = YES;
    [self.destiLabel  addGestureRecognizer:tap12];
    UITapGestureRecognizer *tap13 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGestureAlert:)];
    self.truckTypeLabel.tag = 113;
    self.truckTypeLabel.userInteractionEnabled = YES;
    [self.truckTypeLabel  addGestureRecognizer:tap13];
    UITapGestureRecognizer *tap14 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGestureAlert:)];
    self.goodsTypeLabel.tag = 114;
    self.goodsTypeLabel.userInteractionEnabled = YES;
    [self.goodsTypeLabel  addGestureRecognizer:tap14];
    
    UITapGestureRecognizer *tap15 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGestureAlert:)];
    self.timeLabel.tag = 115;
    self.timeLabel.userInteractionEnabled = YES;
    [self.timeLabel  addGestureRecognizer:tap15];
    
    UITapGestureRecognizer *tap16 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapGestureAlert:)];
    self.otherLabel.tag = 116;
    self.otherLabel.userInteractionEnabled = YES;
    [self.otherLabel  addGestureRecognizer:tap16];
    self.goodstypeString = @"";
    self.strattimeString = @"";
    self.paytypeString = @"";
    self.addtypeString = @"";
    self.remarkString = @"";
}
- (void)initialData{
    self.otherLabel.text = @"装卸方式、付款方式、备注";
    self.otherLabel.textColor = [UIColor darkGrayColor];
    self.timeLabel.text = @"点击选择";
    self.timeLabel.textColor = [UIColor darkGrayColor];
    self.heavyTextField.text = @"";
    self.moneyTextField.text = @"";
    self.goodsTypeLabel.text = @"点击选择";
    self.goodsTypeLabel.textColor = [UIColor darkGrayColor];
    self.truckTypeLabel.text = @"点击选择";
    self.truckTypeLabel.textColor = [UIColor darkGrayColor];
    self.goodstypeString = @"";
    self.strattimeString = @"";
    self.paytypeString = @"";
    self.addtypeString = @"";
    self.remarkString = @"";
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSCharacterSet *cs;
    if(textField == self.heavyTextField || textField == self.moneyTextField)
    {
        cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS] invertedSet];
        NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
        BOOL basicTest = [string isEqualToString:filtered];
        if(!basicTest)
        {
            return NO;
        }
    }
    return YES;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.moneyTextField resignFirstResponder];
    [self.heavyTextField resignFirstResponder];
}
#pragma mark ---- 网络请求
- (IBAction)conformInputMessage:(UIButton *)sender {
    if (self.startAddressString == nil || self.startAddressString.length <= 0) {
        [HTShowUtil showMessage:@"请选择出发地"];
        return;
    }
    if (self.endAddressString == nil || self.endAddressString.length <= 0) {
        [HTShowUtil showMessage:@"请选择目的地"];
        return;
    }
    if (self.cargotypeString == nil || self.cargotypeString.length <= 0 || self.lenghtString == nil || self.lenghtString.length <= 0) {
         [HTShowUtil showMessage:@"请选择车长车型"];
        return;
    }
    if (self.weightString == nil || self.weightString.length <= 0) {
        [HTShowUtil showMessage:@"请输入货物重量"];
        return;
    }
    if (self.pricersString == nil || self.pricersString.length <= 0) {
        [HTShowUtil showMessage:@"请输入运费金额"];
        return;
    }
    [self netLoadData];
    
}
- (void)netLoadData{
    [self startHud];
    [HTHttpRequestManager requestDeliverGoodsWithFromaddress:self.startAddressString toaddress:self.endAddressString fromProvince:self.startProvince toProvince:self.endProvince  cargotype:self.cargotypeString lenght:self.lenghtString lengthtype:self.lengthtypeString weight:self.weightString utit:self.utitString pricers:self.pricersString strattime:self.strattimeString paytype:self.paytypeString addtype:self.addtypeString remark:self.remarkString boostime:self.boostimeString iscity:self.iscityString isworkes:self.isworkesString goodstype:self.goodstypeString success:^(id  _Nullable responseObject) {
        [self endHud];
        DBLog(@"发货---：%@",responseObject);
        if (!responseObject) {
            [HTShowUtil showMessage:@"发货失败"];
            return ;
        }
        NSString *codeStr = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
        if (![codeStr isEqualToString:@"200"]) {
            [HTShowUtil showMessage:responseObject[@"message"]];
            return;
        }
        [HTShowUtil showMessage:responseObject[@"message"]];
        [self initialData];
    } failure:^(NSError * _Nonnull error) {
        [self endHud];
    }];
}
//货物类型
- (NSString *)goodstypeString{
    if (_goodstypeString == nil || _goodstypeString.length <= 0) {
        return @"";
    }
    return _goodstypeString;
}
//时间
- (NSString *)strattimeString{
    if (_strattimeString == nil || _strattimeString.length <= 0) {
        return @"";
    }
    return _strattimeString;
}
//重量
- (NSString *)weightString{
    if (self.heavyTextField.text == nil || self.heavyTextField.text.length <= 0) {
        return @"";
    }else{
        return self.heavyTextField.text;
    }
}
//运费
- (NSString *)pricersString{
    if (self.moneyTextField.text == nil || self.moneyTextField.text.length <= 0) {
        return @"";
    }else{
        return self.moneyTextField.text;
    }
}
//吨/方
- (NSString *)utitString{
    if (self.selectedBtn == self.fangButton) {
        return @"2";
    }
    if (self.selectedBtn == self.dunButton) {
        return @"1";
    }
    return @"1";
}
//20分钟重发15次
- (NSString *)boostimeString{
    if (self.tapLeftImage.hidden) {
        return @"0";
    }else{
        return @"1";
    }
}
//常发货源
- (NSString *)isworkesString{
    if (self.tapMiddleImage.hidden) {
        return @"0";
    }else{
        return @"1";
    }
}
//同城可见
- (NSString *)iscityString{
    if (self.tapRightImage.hidden) {
        return @"0";
    }else{
        return @"1";
    }
}
- (void)netLoadEditData{
    [self startHud];
    [HTHttpRequestManager requestDeliverGoodsInfoWithProductid:self.orderid success:^(id  _Nullable responseObject) {
        [self endHud];
        DBLog(@"编辑数据---：%@",responseObject);
        if (!responseObject) {
            [HTShowUtil showMessage:@"发货失败"];
            return ;
        }
        NSString *codeStr = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
        if (![codeStr isEqualToString:@"200"]) {
            [HTShowUtil showMessage:responseObject[@"message"]];
            return;
        }
        self.deliverGoodsInfoModel = [HTDeliverGoodsInfoModel mj_objectWithKeyValues:responseObject[@"data"]];
    } failure:^(NSError * _Nonnull error) {
        [self endHud];
    }];
}
- (void)setDeliverGoodsInfoModel:(HTDeliverGoodsInfoModel *)deliverGoodsInfoModel{
    _deliverGoodsInfoModel = deliverGoodsInfoModel;
    self.startLabel.text = deliverGoodsInfoModel.fromaddress;
    self.startLabel.textColor = [UIColor blackColor];
    self.startAddressString = deliverGoodsInfoModel.fromaddress;
    self.startProvince = deliverGoodsInfoModel.fromprovice;
    self.endProvince = deliverGoodsInfoModel.toprovice;
    self.destiLabel.text = deliverGoodsInfoModel.toaddress;
    self.endAddressString = deliverGoodsInfoModel.toaddress;
    self.destiLabel.textColor = [UIColor blackColor];
    NSString *total = @"";
    self.cargotypeString = deliverGoodsInfoModel.cargotype;
    if ([self.cargotypeString isEqualToString: @"1"]) {
         total = @"零担";
    }else{
        total = @"整车";
    }
    self.lengthtypeString = deliverGoodsInfoModel.lengthtype;
    self.lenghtString = deliverGoodsInfoModel.lenght;
    NSString *length = [HTUtils sortLengthDisplayStringWith:deliverGoodsInfoModel.lenght];
    if (self.lengthtypeString.length <= 0) {
         total = [NSString stringWithFormat:@"%@ 不限车型 %@",length,total];
    }else{
         total = [NSString stringWithFormat:@"%@ %@ %@",length,self.lengthtypeString,total];
    }
    self.truckTypeLabel.text = total;
    self.truckTypeLabel.textColor = [UIColor blackColor];
    self.heavyTextField.text = deliverGoodsInfoModel.weight;
    if ([deliverGoodsInfoModel.utit isEqualToString:@"1"]) {
        [self clickDun:self.dunButton];
    }else{
        [self clickFang:self.fangButton];
    }
    self.moneyTextField.text = deliverGoodsInfoModel.pricers;
    if ([deliverGoodsInfoModel.boostime isEqualToString:@"0"]) {//没选中
        self.tapLeftImage.hidden = YES;
        [self didTapGesture:self.tap1];
    }else{
        self.tapLeftImage.hidden = NO;
        [self didTapGesture:self.tap1];
    }
    if ([deliverGoodsInfoModel.isworkes isEqualToString:@"0"]) {
        self.tapMiddleImage.hidden = YES;
        [self didTapGesture:self.tap2];
    }else{
        self.tapMiddleImage.hidden = NO;
        [self didTapGesture:self.tap2];
    }
    if ([deliverGoodsInfoModel.iscity isEqualToString:@"0"]) {
        self.tapRightImage.hidden = YES;
        [self didTapGesture:self.tap3];
    }else{
        self.tapRightImage.hidden = NO;
        [self didTapGesture:self.tap3];
    }
}
@end
